package com.chencs.utils;

import java.text.DecimalFormat;

/**
 * Created by fangzehua on 2017/7/4.
 */
public class MoneyUtils {

    /**
     * 佣金转换
     * @param commission
     * @param commissionrate
     * @return
     */
    public static String commissionrate(String commission,String commissionrate){
        double comm = Double.parseDouble(commission);
        double rate = Double.parseDouble(commissionrate);
        return m2(comm * (rate*0.01));
    }

    /**
     * 保留两位小数
     * @param data
     * @return
     */
    public static String m2(double data) {
        DecimalFormat df = new DecimalFormat("#.00");
      return df.format(data);
     }


    public static String getCmd(String x) {
        String cmd = "";

        try {
            cmd = x.replace("我剁手都要买的宝贝（","").replace("），快来和我一起瓜分红包","");
        }catch (Exception e){
            e.printStackTrace();
            cmd = x;
        }

        return cmd;
    }

    public static String getCmPrice(String x) {
        String cmd = "0.00";

        try {
            cmd = x.split("&")[0].split("price=")[1];
        }catch (Exception e){
          //  e.printStackTrace();
            cmd ="0";
        }

        return cmd;
    }


}
